package com.elm.deliveryaddress.mapper;


import com.elm.deliveryaddress.pojo.DeliveryAddress;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface DeliveryAddressMapper {

    @Select("select * from deliveryaddress where userId=#{userId}")
    List<DeliveryAddress> listDeliveryAddressByUserId(String userId);

    @Select("select * from deliveryaddress where daId=#{daId}")
    DeliveryAddress getDeliveryAddressById(Integer daId);

    @Insert("insert into deliveryaddress(contactName,contactSex,contactTel,address,userId)" +
            " values (#{contactName},#{contactSex},#{contactTel},#{address},#{userId})")
    Integer saveDeliveryAddress(DeliveryAddress deliveryAddress);

    @Update("update deliveryaddress set contactName=#{contactName},contactSex=#{contactSex},contactTel=#{contactTel},address=#{address}," +
            "userId=#{userId} where daId=#{daId}")
    Integer updateDeliveryAddress(DeliveryAddress deliveryAddress);

    @Delete("delete from deliveryaddress where daId=#{daId}")
    Integer removeDeliveryAddress(Integer daId);
}
